// pages/answers/answers.js
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    wx.getSystemInfo({
      success: function (res) {
        that.setData({
          winWidth: res.windowWidth,
          winHeight: res.windowHeight,
        })
      }
    })
    if (options.question_id) {
      that.setData({
        question_id: options.question_id,
        user_id: options.user_id
      })
    }
    getAnswer(that);
  },
})



function getAnswer(that) {
  wx.request({
    url: app.globalData.allUrl + "/api/see_answer.php",
    data: {
      user_id: that.data.user_id,
      question_id: that.data.question_id
    },
    header: { 'content-type': "application/x-www-form-urlencoded" },
    method: 'POST',
    success: function (res) {
      console.log(res.data)
      that.setData({
        allAnswers: res.data.data,
      })
    }, fail: function () {
    }
  })
}